package com.example.photography.fragment.product;

import android.widget.GridView;

import com.alibaba.fastjson.JSONObject;
import com.example.photography.R;
import com.example.photography.adapter.product.ArticleAdapter;
import com.example.photography.bean.ArticlesBean;
import com.example.photography.bean.PicturesBean;
import com.example.photography.bean.ProductBean;
import com.example.photography.bean.UserBean;
import com.example.photography.common.BaseFragment;
import com.example.photography.util.Util;
import com.loopj.android.http.RequestParams;

import java.util.List;
import java.util.Objects;

import butterknife.BindView;

import static com.example.photography.util.Util.getJson;

public class Product_Article extends BaseFragment {
    @BindView(R.id.gv_item)
    GridView gvItem;
    private List<ArticlesBean.DataBean.ArticleBean> article;
    private ArticlesBean articlesBean;

    public Product_Article() {
    }

    @Override
    protected RequestParams getParams() {
        return null;
    }

    @Override
    protected String getUrl() {
        return null;
    }

    @Override
    protected void initData(String content) {
        String json = getJson(Objects.requireNonNull(getActivity()), "article.json");
        if (!json.isEmpty()) {
            articlesBean = JSONObject.parseObject(json, ArticlesBean.class);
        }
        article = articlesBean.getData().getArticle();
        ArticleAdapter articleAdapter = new ArticleAdapter(article, getActivity()) {
            @Override
            public void setItemListen(int id) {
                Util.showToast(getActivity(), "item_id:"+id);
            }
        };
        gvItem.setAdapter(articleAdapter);
    }

    @Override
    public int getLayoutId() {
        return R.layout.product_article;
    }
}
